package com.example.springbott.wx_controller;

import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketKeyword;
import com.example.springbott.vo.WxSearchIndex;
import com.example.springbott.wx_service.WxSearchService;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 付常莹
 * @description: TODO
 * @date 2022/11/22 11:21
 *
 *该Controller用于小程序首页搜索模块
 */
@RestController
@RequestMapping("/wx/search")
public class WxSearchController {
    @Resource
    WxSearchService wxSearchService;

    /**
     * 该方法用于输入框输入搜索
     * 用于小程序模块
     */
    @GetMapping("index")
    public BaseRespVo index(){
        WxSearchIndex wxSearchIndex =wxSearchService.index();
        return BaseRespVo.ok(wxSearchIndex);
    }


    /**
     * 该方法用于关键词搜索
     * @param
     * @return
     */
    @GetMapping("helper")
    public BaseRespVo helper(String keyword){
        List<String> data =  wxSearchService.helper(keyword);
        return BaseRespVo.ok(data);
    }


    /**
     * 该方法用于删除用户个人的历史记录
     * @return
     */
    @GetMapping("clearhistory")
    public BaseRespVo clearHistory(){
        wxSearchService.delete();
        return BaseRespVo.ok();
    }


}
